home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / vbchat1a / chat.frm (.txt) next >
Encoding:
Visual Basic Form  |  1999-08-30  |  10.1 KB  |  336 lines

  1. VERSION 5.00
  2. Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
  3. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  4. Begin VB.MDIForm MDIForm1 
  5.    BackColor       =   &H8000000C&
  6.    Caption         =   "Vb chat"
  7.    ClientHeight    =   5055
  8.    ClientLeft      =   165
  9.    ClientTop       =   735
  10.    ClientWidth     =   7080
  11.    LinkTopic       =   "MDIForm1"
  12.    StartUpPosition =   3  'Windows Default
  13.    WindowState     =   2  'Maximized
  14.    Begin VB.PictureBox Picture3 
  15.       Align           =   2  'Align Bottom
  16.       BorderStyle     =   0  'None
  17.       Height          =   360
  18.       Left            =   0
  19.       ScaleHeight     =   360
  20.       ScaleWidth      =   7080
  21.       TabIndex        =   5
  22.       Top             =   4695
  23.       Width           =   7080
  24.       Begin MSComctlLib.ProgressBar ProgressBar1 
  25.          Height          =   135
  26.          Left            =   1560
  27.          TabIndex        =   6
  28.          Top             =   120
  29.          Width           =   2655
  30.          _ExtentX        =   4683
  31.          _ExtentY        =   238
  32.          _Version        =   393216
  33.          Appearance      =   0
  34.       End
  35.       Begin VB.Label Label3 
  36.          AutoSize        =   -1  'True
  37.          BackStyle       =   0  'Transparent
  38.          Caption         =   "Mostafa Mohamed web page"
  39.          BeginProperty Font 
  40.             Name            =   "MS Sans Serif"
  41.             Size            =   8.25
  42.             Charset         =   0
  43.             Weight          =   400
  44.             Underline       =   -1  'True
  45.             Italic          =   0   'False
  46.             Strikethrough   =   0   'False
  47.          EndProperty
  48.          ForeColor       =   &H00FF0000&
  49.          Height          =   195
  50.          Left            =   4320
  51.          MouseIcon       =   "chat.frx":0000
  52.          MousePointer    =   99  'Custom
  53.          TabIndex        =   8
  54.          Top             =   90
  55.          Width           =   2070
  56.       End
  57.       Begin VB.Label Label2 
  58.          AutoSize        =   -1  'True
  59.          BackStyle       =   0  'Transparent
  60.          Caption         =   "Sending progress:"
  61.          BeginProperty Font 
  62.             Name            =   "MS Sans Serif"
  63.             Size            =   8.25
  64.             Charset         =   0
  65.             Weight          =   400
  66.             Underline       =   -1  'True
  67.             Italic          =   0   'False
  68.             Strikethrough   =   0   'False
  69.          EndProperty
  70.          Height          =   195
  71.          Left            =   120
  72.          TabIndex        =   7
  73.          Top             =   60
  74.          Width           =   1275
  75.       End
  76.    End
  77.    Begin VB.Timer Timer2 
  78.       Interval        =   1
  79.       Left            =   1680
  80.       Top             =   0
  81.    End
  82.    Begin VB.Timer Timer1 
  83.       Interval        =   1000
  84.       Left            =   1320
  85.       Top             =   0
  86.    End
  87.    Begin MSWinsockLib.Winsock sck 
  88.       Left            =   960
  89.       Top             =   0
  90.       _ExtentX        =   741
  91.       _ExtentY        =   741
  92.       _Version        =   393216
  93.    End
  94.    Begin VB.PictureBox Picture2 
  95.       Align           =   1  'Align Top
  96.       BorderStyle     =   0  'None
  97.       Height          =   495
  98.       Left            =   0
  99.       ScaleHeight     =   495
  100.       ScaleWidth      =   7080
  101.       TabIndex        =   3
  102.       Top             =   0
  103.       Width           =   7080
  104.       Begin VB.CommandButton Command1 
  105.          Caption         =   "Command1"
  106.          Height          =   495
  107.          Index           =   0
  108.          Left            =   0
  109.          Picture         =   "chat.frx":0152
  110.          Style           =   1  'Graphical
  111.          TabIndex        =   4
  112.          Top             =   0
  113.          Visible         =   0   'False
  114.          Width           =   975
  115.       End
  116.    End
  117.    Begin VB.PictureBox Picture1 
  118.       Align           =   4  'Align Right
  119.       BorderStyle     =   0  'None
  120.       Height          =   4200
  121.       Left            =   4785
  122.       ScaleHeight     =   4200
  123.       ScaleWidth      =   2295
  124.       TabIndex        =   0
  125.       Top             =   495
  126.       Width           =   2295
  127.       Begin VB.ListBox List1 
  128.          Enabled         =   0   'False
  129.          Height          =   4155
  130.          ItemData        =   "chat.frx":0494
  131.          Left            =   0
  132.          List            =   "chat.frx":0496
  133.          TabIndex        =   1
  134.          Top             =   360
  135.          Width           =   2295
  136.       End
  137.       Begin VB.Label Label1 
  138.          AutoSize        =   -1  'True
  139.          BackStyle       =   0  'Transparent
  140.          Caption         =   "Available users:-"
  141.          BeginProperty Font 
  142.             Name            =   "MS Sans Serif"
  143.             Size            =   8.25
  144.             Charset         =   0
  145.             Weight          =   400
  146.             Underline       =   -1  'True
  147.             Italic          =   0   'False
  148.             Strikethrough   =   0   'False
  149.          EndProperty
  150.          Height          =   195
  151.          Left            =   120
  152.          TabIndex        =   2
  153.          Top             =   120
  154.          Width           =   1155
  155.       End
  156.    End
  157.    Begin VB.Menu mnufile 
  158.       Caption         =   "File"
  159.       Begin VB.Menu mnuconnect 
  160.          Caption         =   "Connect"
  161.       End
  162.       Begin VB.Menu mnuexit 
  163.          Caption         =   "Exit"
  164.       End
  165.    End
  166. Attribute VB_Name = "MDIForm1"
  167. Attribute VB_GlobalNameSpace = False
  168. Attribute VB_Creatable = False
  169. Attribute VB_PredeclaredId = True
  170. Attribute VB_Exposed = False
  171. Dim lastindex As Integer
  172. Dim tex As String
  173. Private Sub Command1_Click(Index As Integer)
  174. On Error Resume Next
  175. Form1.Picture1(Index).Visible = True
  176. Form1.Picture1(Index).ZOrder 0
  177. End Sub
  178. Private Sub Label3_Click()
  179. On Error Resume Next
  180. Shell "explorer http://www.geocities.com/ResearchTriangle/Campus/4598/", vbNormalFocus
  181. End Sub
  182. Private Sub List1_Click()
  183. On Error Resume Next
  184. Load Command1(List1.ListIndex)
  185. Command1(List1.ListIndex).Visible = True
  186. Command1(List1.ListIndex).Left = 0
  187. Command1(List1.ListIndex).Top = 0
  188. Command1(List1.ListIndex).Caption = List1.List(List1.ListIndex)
  189. lastindex = List1.ListIndex
  190. Form1.loadfrm List1.ListIndex
  191. Form1.Label1(List1.ListIndex).Caption = List1.List(List1.ListIndex)
  192. End Sub
  193. Private Sub MDIForm_Load()
  194. lastindex = 0
  195. End Sub
  196. Private Sub MDIForm_Unload(Cancel As Integer)
  197. On Error Resume Next
  198. sck.SendData "closed=>:" & user.Nickname
  199. Picture2.Visible = False
  200. Unload Form1
  201. List1.Enabled = False
  202. sck.Close
  203. End Sub
  204. Private Sub mnuconnect_Click()
  205. On Error Resume Next
  206. If mnuconnect.Caption = "Connect" Then
  207. sck.Close
  208. Form1.Show
  209. List1.Clear
  210. frmLogin.Show vbModal
  211. mnuconnect.Caption = "Disconnect"
  212. Picture2.Visible = True
  213. List1.Enabled = True
  214. Exit Sub
  215. sck.SendData "closed=>:" & user.Nickname
  216. mnuconnect.Caption = "Connect"
  217. Picture2.Visible = False
  218. Unload Form1
  219. List1.Enabled = False
  220. Exit Sub
  221. End If
  222. End Sub
  223. Private Sub mnuexit_Click()
  224. On Error Resume Next
  225. sck.SendData "closed=>:" & user.Nickname
  226. Picture2.Visible = False
  227. Unload Form1
  228. List1.Enabled = False
  229. sck.Close
  230. End Sub
  231. Private Sub Picture1_Resize()
  232. List1.Height = Picture1.ScaleHeight - List1.Top
  233. End Sub
  234. Private Sub sck_Connect()
  235. On Error Resume Next
  236. MDIForm1.sck.SendData "adduser" & "=>:" & user.Name & "=>:" & user.Nickname & "=>:" & user.ip
  237. End Sub
  238. Private Sub sck_DataArrival(ByVal bytesTotal As Long)
  239. On Error Resume Next
  240.  Dim start As Integer
  241.   Dim str As String
  242.   Dim res As VbMsgBoxResult
  243.   Dim splited() As String
  244.   Dim arriveddata As String
  245. Dim start2 As Integer
  246.    sck.GetData arriveddata, vbString
  247.    DoEvents
  248.   start = 1
  249.   DoEvents
  250.     chrpos = InStr(start, arriveddata, "|", vbTextCompare)
  251.     start2 = start
  252.      X = chrpos
  253.       start = chrpos + 1
  254.     If chrpos <> 1 Then
  255.    If chrpos <> 0 Then
  256.       
  257.       str = Mid(arriveddata, start2, chrpos - start2)
  258.      
  259.       splited() = Split(str, "=>:")
  260.       
  261.       If str <> "" Then
  262.      '-------------------
  263.      Select Case splited(0)
  264.      Case "serverinfo"
  265.      Form1.Text3.SelStart = Len(Form1.Text3.Text)
  266.      Form1.Text3.SelText = "<< Server message >> " & splited(1) & vbCrLf
  267.       Case "message"
  268.      Form1.Text3.SelStart = Len(Form1.Text3.Text)
  269.      Form1.Text3.SelText = "<< message >> " & splited(1) & vbCrLf
  270.        '-------------
  271.        Case "user"
  272.        List1.AddItem splited(1)
  273.       '-------------------------------
  274.         Case "mssg"
  275.         For i = 0 To 50
  276.         If Form1.Label1(i).Caption = splited(1) Then
  277.         
  278.         Form1.Text1(i).SelStart = Len(Form1.Text1(i).Text)
  279.        tex = splited(1) & ":" & splited(2)
  280.         Form1.Text1(i).SelText = vbCrLf
  281.         Form1.Text1(i).SelText = tex & vbCrLf
  282.         End If
  283.         Next i
  284.         '--------------------------
  285.           Case "leave"
  286.      On Error Resume Next
  287. For i = 0 To List1.ListCount
  288. If List1.List(i) = splited(1) Then
  289. List1.RemoveItem i
  290. End If
  291. Next i
  292. '----------------------------------
  293.         Case "ping"
  294.         
  295.         res = MsgBox(splited(1) & " want to make chat with you,do you want to make connection with him?", vbYesNo)
  296.       If res = vbYes Then
  297.       For i = 0 To 50
  298.       If List1.List(i) = splited(1) Then
  299.       Form1.loadfrm (i)
  300.       Form1.Label1(i).Caption = splited(1)
  301.       End If
  302.     Next i
  303.     End If
  304.     '-----------------------------------
  305.             Case "kicked"
  306.         MsgBox splited(1) & " has kicked you."
  307.       End Select
  308.       DoEvents
  309.       End If
  310.     Else
  311.     Exit Do
  312.    End If
  313.    End If
  314.   Loop Until X = Len(arriveddata) - 1
  315. End Sub
  316. Private Sub sck_SendProgress(ByVal bytesSent As Long, ByVal bytesRemaining As Long)
  317. On Error Resume Next
  318. ProgressBar1.Value = 0
  319. ProgressBar1.Max = bytesSent + bytesRemaining
  320. ProgressBar1.Value = bytesSent
  321. End Sub
  322. Private Sub Timer1_Timer()
  323. On Error Resume Next
  324. For i = 0 To List1.ListCount
  325. If List1.List(i) = "" Or List1.List(i) = user.Nickname Then
  326. List1.RemoveItem i
  327. End If
  328. Next i
  329. End Sub
  330. Private Sub Timer2_Timer()
  331. On Error Resume Next
  332. For i = 0 To 50
  333. Command1(i).Left = Command1(i - 1).Left + Command1(i).Width + 10
  334. Next i
  335. End Sub
  336.